<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>小黑记事本</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta name="robots" content="noindex, nofollow" />
    <meta name="googlebot" content="noindex, nofollow" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="stylesheet" type="text/css" href="./css/index.css" />
  </head

  <body>
  <!-- 主体区域 -->
  <section id="todoapp">
    <!-- 输入框 -->
    <header class="header">
      <h1>小黑记事本</h1>
      <input v-model="inputValue" @keyup.enter="addAct" autofocus="autofocus" autocomplete="off" placeholder="请输入任务"
        class="new-todo" />
    </header>

    <!-- 列表区域 -->
    <section class="main">
      <ul class="todo-list">
        <li class="todo" v-for="(item,aindex) in list">
          <div class="view">
            <span class="index">{{aindex +1}}. </span>
            <label> {{item}} </label>
           
            <!-- 删除：实现点击后删除谁。当前索引的元素      -->
            <button class="destroy" @click="deleteAct(aindex)"> </button>
          </div>
        </li>
      </ul>
    </section>

    <!-- 统计和清空 -->
    <footer  class="footer" >
      <span v-show="list.length!=0" class="todo-count">
        <strong>{{list.length}}</strong> items left
      </span>
      <button @click="clearAct" v-if="list.length!=0" class="clear-completed">
        Clear
      </button>
    </footer>

  </section>

  
     <!-- 底部 -->
     <footer class="info">
      <p>
        <a href="http://www.itheima.com/"><img src="./img/black.png" alt="" /></a>
      </p>
    </footer>
    

    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>


    <script>
      new Vue({
        el:"#todoapp",
        data:{
          list:["学习1","学习2","学习3"],
          inputValue:"学习4"
        },
        methods: {
          addAct:function(){
            this.list.push(this.inputValue);
            // list.push();
          },
          deleteAct:function(aIndex){ //删除指定下标的数组元素
            console.log("删除");
            console.log(aIndex);
            this.list.splice(aIndex,1); //从index位置开始删除一个
          },
          clearAct:function(){
            this.list.splice(0, this.list.length);
          }
        
        },

      })
    </script>

    <!-- data是这个Vue实例中使用到的数据。用什么就写什么 -->
  </body>
</html>
